package com.si.sea_island.mapper;

import com.si.sea_island.pojo.game.Island;
import com.si.sea_island.pojo.game.Lands;
import com.si.sea_island.pojo.game.Result;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Component;

import java.util.Date;
import java.util.List;

/**
 * @Description IslandMapper
 * @Author weijunhao
 * @Date 2024-12-17
 */

@Component
public interface IslandMapper {


    @Select("select `t1`.`tid` AS `tId`,`t1`.`type` AS `unlock`,`t2`.`product` from si_game_island t2 left join si_game_island_user t1 on t1.tid =t2.id where uid = #{id};")
    List<Island> getIslandList(int id);

    @Select("select price from si_game_island where id = #{tId}")
    String getIslandPrice(Integer tId);

    @Update("update si_game_island_user set type = 1,lastFetchTime = #{lastFetchTime} where tid = #{tId} and uid = #{uid};")
    void update(int uid, Integer tId,String lastFetchTime);

    @Select("select count(*) from si_game_island;")
    int selectIslandNum();

    @Insert("insert into si_game_island_user(tid,uid) values (#{tid},#{userId});")
    void insertNewUser(int tid, int userId);

    @Select("select product from si_game_island where id = #{tId}")
    Integer product(Integer tId);

    @Select("select id from si_game_island where id = #{tId}")
    Integer getIslandById(Integer tId);

    @Select("select name from si_game_island where id = #{tId}")
    String getIslandNameById(Integer tId);


    
  
    @Select("select * from si_lands where tid = #{tid} and uid = #{id};")
    List<Lands> getliat(Integer tid, int id);

    @Select("select * from si_lands where tid = #{tid} and uid = #{id} ;")
    Lands getland(Integer tid, int id);


    @Update("update si_lands set fld = #{fld1} where tid = #{tid} and uid = #{id} and `index` = #{index};")
    void updatePlant(Integer tid, Integer fld1, int id,Integer index);


    @Update("update si_lands set downTime = #{beijingTime} where tid = #{tid} and uid = #{id} and `index` = #{index};")
    void updateTime(Integer tid, String beijingTime, int id, Integer index);

    @Select("select * from si_lands where tid = #{tid} and uid = #{id};")
    Result getlands(Integer tid, int id);

    @Select("select `type` from si_game_island_user where tid = #{tid} and uid = #{id}")
    Integer getIslandId(Integer tid, int id);

    @Insert("insert into si_lands(tid,uid,`index`,downTime) values (#{tId},#{uid},1,#{lastFetchTime});")
    void insertLands(int uid, Integer tId, String lastFetchTime);
}
